package week4;

/**
 * Created by dell on 2017/3/18.
 */
public class MultiChat {
    public static void main(String[] args) {
        Client c1 = new Client("127.0.1.0","Caterpillar");
        Client c2 = new Client("192.168.0.2","Justin");

        ClientQueue queue = new ClientQueue();
        queue.addClientListener(new ClientListener() {
            @Override
            public void clientAdded(ClientEvent event) {
                System.out.printf("%s 从 %s 联机 %n",event.getName(), event.getIp());
            }

            @Override
            public void clientRemoved(ClientEvent event) {
                System.out.printf("%s 从 %s 脱机 %n",event.getName(), event.getIp());
            }
        });

        queue.add(c1);
        queue.add(c2);
        queue.remove(c1);
        queue.remove(c2);
    }
}
